package com.qezhhnjy.mall.order.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qezhhnjy.mall.common.entity.order.OrderReturnApply;
import com.qezhhnjy.mall.common.http.BaseResult;
import com.qezhhnjy.mall.order.service.OrderReturnApplyService;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 订单退货申请 前端控制器
 * </p>
 *
 * @author qezhhnjy
 * @since 2021-06-27
 */
@RestController
@Api(tags = "订单退货申请接口")
@Slf4j
@RequestMapping("/order-return-apply")
public class OrderReturnApplyController {
    @Resource
    private OrderReturnApplyService orderReturnApplyService;

    @GetMapping("/get")
    @Operation(summary = "根据id获取订单退货申请信息")
    public BaseResult<OrderReturnApply> get(Long id) {
        OrderReturnApply orderReturnApply = orderReturnApplyService.getById(id);
        return BaseResult.success(orderReturnApply);
    }

    @PostMapping("/save")
    @Operation(summary = "新增订单退货申请信息")
    public BaseResult<OrderReturnApply> save(@RequestBody OrderReturnApply orderReturnApply) {
        orderReturnApplyService.save(orderReturnApply);
        return BaseResult.success(orderReturnApply);
    }

    @PutMapping("/update")
    @Operation(summary = "更新订单退货申请信息")
    public BaseResult<OrderReturnApply> update(@RequestBody OrderReturnApply orderReturnApply) {
        orderReturnApplyService.updateById(orderReturnApply);
        return BaseResult.success(orderReturnApply);
    }

    @PostMapping("/page")
    @Operation(summary = "分页获取订单退货申请信息")
    public BaseResult<Page<OrderReturnApply>> page(@RequestBody Page<OrderReturnApply> page) {
        orderReturnApplyService.page(page);
        return BaseResult.success(page);
    }

    @DeleteMapping("/delete")
    @Operation(summary = "根据id删除订单退货申请信息")
    public BaseResult<Long> delete(Long id) {
        orderReturnApplyService.removeById(id);
        return BaseResult.success(id);
    }
}

